<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
$(function(){
	$("input[name='multipleDialogMyIds']").each(function(){
		if($(this).attr("value") != null){
			$("input[name='multipleDialogMyIds']").val($(this).attr("value"));
			$(this).attr("id","multipleDialogMyIds");
		}
	});
	$("input[name='multipleDialogMyNames']").each(function(){
		if($(this).attr("value") != null){
			$("input[name='multipleDialogMyNames']").val($(this).attr("value"));
			$(this).attr("id","multipleDialogMyNames");
		}
	});
});
var myIds = $("#multipleDialogMyIds").val();
var myNames = $("#multipleDialogMyNames").val();

$(function(){
	$("input[name='ids']").each(function(){
		var theIds = myIds.split(",");
		var thisId = $(this).attr("value");
		for(var i = 0;i<theIds.length;i ++){
			if(thisId == theIds[i]){
				$(this).attr("checked","checked");
				break;
			}
		}
	});
});

function checkBoxClick(obj){
	var strings = obj.split(":");
	if(myIds.indexOf(strings[0]) >= 0){
		myIds=(","+myIds).replace(","+strings[0]+",",",").substring(1); 
		myNames=(","+myNames).replace(","+strings[1]+",",",").substring(1); 
	}else{
		myIds += strings[0]+",";
    	myNames += strings[1]+",";
	}
	$("input[name='multipleDialogMyIds']").val(myIds);
	$("input[name='multipleDialogMyNames']").val(myNames);
}
function sureBack(){
	$.bringBack({id:myIds,name:myNames});
};

</script>
<form id="pagerForm" method="post" model="viewRequest" action="#rel#"  >
	<input type="hidden" name="viewRequest.page" value="${page.number}" />
	<input type="hidden" name="viewRequest.size" value="${page.size}" />
	
	<input type="hidden" name="multipleDialogMyIds" value="${multipleDialogMyIds }">
	已选品牌：<input type="text" name="multipleDialogMyNames" value="${multipleDialogMyNames }" style="width:700px">
		<input type="button" onclick="sureBack()" value="确定">
	
	<c:forEach items="${viewRequest.params}" var="params">
		<input type="hidden" id="${params.key}" name="viewRequest.params['${params.key}']" value="${params.value}" />
	</c:forEach>
	<c:forEach items="${viewRequest.sort}" var="sort">
		<input type="hidden" name="viewRequest.sort.${sort.key}" value="${sort.value}" />
	</c:forEach>
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return dialogSearch(this);" action="${rootUrl}/goods/brand/0/multipleDialog" method="post">
	<input type="hidden" name="multipleDialogMyIds" value="${multipleDialogMyIds }">
	<input type="hidden" name="multipleDialogMyNames" value="${multipleDialogMyNames }">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label>内容检索：</label>
				<input type="text" name="search_content" value="${search_content}"/>
			</li>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
		<table class="table" targetType="dialog"  width="100%" layoutH="150">
		<thead>
			<tr>
				<th width="22"></th>
				<th width="30" align="center" >序号</th>
				<th width="100">品牌编码</th>
				<th width="200">品牌名称</th>
				<th width="100">排序</th>
				<th width="100">是否展示</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.content}" var="brand" varStatus="status">
				<td><input name="ids" value="${brand.id }" type="checkbox" onclick="checkBoxClick('${brand.id}:${brand.name}')"></td>
				<td>${status.count}</td>
				<td>${brand.code}</td>
				<td>${brand.name}</td>
				<td>${brand.sort}</td>
				<td>${brand.isShow==1?"展示":"隐藏"}</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="dialogPageBreak({numPerPage:this.value})">
				<option value="${page.size}">${page.size}</option>
				<option value="20">20</option>
				<option value="50">50</option>
				<option value="100">100</option>
				<option value="200">200</option>
			</select>
			<span>条，共${page.totalElements}条 </span>
		</div>
		<div class="pagination" targetType="dialog" totalCount="${page.totalElements}" numPerPage="${page.size}" pageNumShown="10" currentPage="${page.number}"></div>
	</div>
</div>